#include<bits/stdc++.h>
using namespace std;
#define int long long

int vis[100], ans[100];

void dfs(int n, int k, int num) {
	if (num == k) {
		for (int i = 1; i <= k; i++)
			cout << setw(3) << ans[i];
		cout << endl;
		return ;
	}

	for (int i = 1; i <= n; i++) {
		if (!vis[i] && i > ans[num]) {
			vis[i] = 1;
			ans[num + 1] = i;
			dfs(n, k, num + 1);
			vis[i] = 0;
		}
	}
}

signed main() {
	int n, k;
	cin >> n >> k;
	dfs(n, k, 0);
	return 0;
}
